<?php

/*

  Treasure  $6

  Worth $2.
  While this is in play, when you buy a Victory card, gain a Gold.

 */

class Hoard extends Card implements iTreasure, iKingdom, iProsperity, iReactingCard {

    private $reactConditions;

    public function __construct() {
        parent::__construct("Hoard", 6);
        $this->value = new Price(2);
        $this->undoPlay = false;
        $this->undoBuy = true;

        $this->reactConditions = new ReactionConditions();
        $this->reactConditions->action = array(Buy);
        $this->reactConditions->actor = array(Yourself);
        $this->reactConditions->cardLocation = array(PlayArea);
        $this->reactConditions->limit = ForEachCard;
        $this->reactConditions->isMandatory = true;
    }

    public function getDescription() {
        return array(
            "Worth $2",
            " While this is in play, when you buy a Victory card, gain a Gold.");
    }
    
    public function autoPlayNum(Game $game) {
        return -1;
    }

    public function getConditions() {
        return $this->reactConditions;
    }

    public function isReactRelevant(Game $game, $card, $name) {
        if ($card instanceof iVictory) 
            return true;
        return false;
    }

    public function react(Game $game, $card, $name) {
        if ($card instanceof iVictory) {
            ScreenDisplay::addScreenMessage($game, true, "activate ".  nicePrint($this), "activates ".  nicePrint($this), $name);
            $gold = $game->moveCardFromPileToPile("Gold", BoardCards, DiscardPile, $name);
            ScreenDisplay::addScreenMessage($game, false, " and gain " . nicePrint($gold), " and gains " . ScreenDisplay::$LMSG, $name);
            $game->setTempCard($card);
        }
        return true;
    }


}

?>